

import 'package:flutter/material.dart';

/// refresh indicator learn
class RefreshLearn extends StatefulWidget {
  const RefreshLearn({Key? key}) : super(key: key);

  @override
  _RefreshLearnState createState() => _RefreshLearnState();
}

class _RefreshLearnState extends State<RefreshLearn> {
  initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
        child: Scaffold(
      appBar: AppBar(
        title: Text("RefreshIndicator"),
      ),
      body: RefreshIndicator(
          color: Colors.blue,
          //下拉停止的距离
          displacement: 44.0,
          onRefresh: () async {
            print("this is fresh");
          },
          child: CustomScrollView(
            slivers: [
              SliverToBoxAdapter(
                child: Text("qwer"),
              ),
              SliverToBoxAdapter(
                  child: ListView.builder(
                      shrinkWrap: true,
                      itemCount: 10,
                      itemBuilder: (_, index) {
                        return Text("data$index");
                      })),
              SliverList(
                delegate: SliverChildBuilderDelegate((content, index) {
                  return Container(
                    height: 65,
                    color: Colors.primaries[index % Colors.primaries.length],
                  );
                }, childCount: 20),
              )
            ],
          )),
    ));
  }
}
